package com.me.mygdxgame;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
enum ReSourceID
{
	RED00,
	RED10,
	RED20,
	RED30,
	RED40,
	RED50,
	RED60,
	RED70,
	RED80,
	RED90,
	BLUE00,
	BLUE10,
	BLUE20,
	BLUE30,
	BLUE40,
	BLUE50,
	BLUE60,
	BLUE70,
	BLUE80,
	BLUE90,
	BACKGROUND,
	BOUND,
	RESET_BOARD
}
public class ResourceManagement {
	static ResourceManagement m_hInstance = null;
	Sprite m_red00, m_red11, m_red22, m_red33, m_red44, m_red55, m_red66, m_red77, m_red88, m_red99, m_background, m_bound;
	Sprite m_blue00, m_blue11, m_blue22, m_blue33, m_blue44, m_blue55, m_blue66, m_blue77, m_blue88, m_blue99;
	Sprite m_reset_board;
	TextureAtlas m_atlas = new TextureAtlas(Gdx.files.internal("datapacker/filemota.txt"));
	public ResourceManagement() 
	{
		TextureAtlas m_atlas = new TextureAtlas(Gdx.files.internal("datapacker/filemota.txt"));
		m_reset_board = new  Sprite(new TextureRegion(m_atlas.findRegion("xep_lai_ban_co")));
		//quan do
		m_red00 = new Sprite(new TextureRegion(m_atlas.findRegion("do/00")));
		m_red11 = new Sprite(new TextureRegion(m_atlas.findRegion("do/10")));
		m_red22 = new Sprite(new TextureRegion(m_atlas.findRegion("do/20")));
		m_red33 = new Sprite(new TextureRegion(m_atlas.findRegion("do/30")));
		m_red44 = new Sprite(new TextureRegion(m_atlas.findRegion("do/40")));
		m_red55 = new Sprite(new TextureRegion(m_atlas.findRegion("do/50")));
		m_red66 = new Sprite(new TextureRegion(m_atlas.findRegion("do/60")));
		m_red77 = new Sprite(new TextureRegion(m_atlas.findRegion("do/70")));
		m_red88 = new Sprite(new TextureRegion(m_atlas.findRegion("do/80")));
		m_red99 = new Sprite(new TextureRegion(m_atlas.findRegion("do/90")));
		//quan xanh
		m_blue00 = new Sprite(new TextureRegion(m_atlas.findRegion("xanh/00")));
		m_blue11 = new Sprite(new TextureRegion(m_atlas.findRegion("xanh/10")));
		m_blue22 = new Sprite(new TextureRegion(m_atlas.findRegion("xanh/20")));
		m_blue33 = new Sprite(new TextureRegion(m_atlas.findRegion("xanh/30")));
		m_blue44 = new Sprite(new TextureRegion(m_atlas.findRegion("xanh/40")));
		m_blue55 = new Sprite(new TextureRegion(m_atlas.findRegion("xanh/50")));
		m_blue66 = new Sprite(new TextureRegion(m_atlas.findRegion("xanh/60")));
		m_blue77 = new Sprite(new TextureRegion(m_atlas.findRegion("xanh/70")));
		m_blue88 = new Sprite(new TextureRegion(m_atlas.findRegion("xanh/80")));
		m_blue99 = new Sprite(new TextureRegion(m_atlas.findRegion("xanh/90")));
		//
		m_background = new Sprite(new TextureRegion(m_atlas.findRegion("background")));
		m_bound = new Sprite(new TextureRegion(m_atlas.findRegion("bound2")));
		m_red00.setOrigin(m_red00.getWidth()/2, m_red00.getHeight()/2);
		m_red11.setOrigin(m_red11.getWidth()/2, m_red11.getHeight()/2);
		m_red22.setOrigin(m_red22.getWidth()/2, m_red22.getHeight()/2);
		m_red33.setOrigin(m_red33.getWidth()/2, m_red33.getHeight()/2);
		m_red44.setOrigin(m_red44.getWidth()/2, m_red44.getHeight()/2);
		m_red55.setOrigin(m_red55.getWidth()/2, m_red55.getHeight()/2);
		m_red66.setOrigin(m_red66.getWidth()/2, m_red66.getHeight()/2);
		m_red77.setOrigin(m_red77.getWidth()/2, m_red77.getHeight()/2);
		m_red88.setOrigin(m_red88.getWidth()/2, m_red88.getHeight()/2);
		m_red99.setOrigin(m_red99.getWidth()/2, m_red99.getHeight()/2);
		///
		m_blue00.setOrigin(m_blue00.getWidth()/2, m_blue00.getHeight()/2);
		m_blue11.setOrigin(m_blue11.getWidth()/2, m_blue11.getHeight()/2);
		m_blue22.setOrigin(m_blue22.getWidth()/2, m_blue22.getHeight()/2);
		m_blue33.setOrigin(m_blue33.getWidth()/2, m_blue33.getHeight()/2);
		m_blue44.setOrigin(m_blue44.getWidth()/2, m_blue44.getHeight()/2);
		m_blue55.setOrigin(m_blue55.getWidth()/2, m_blue55.getHeight()/2);
		m_blue66.setOrigin(m_blue66.getWidth()/2, m_blue66.getHeight()/2);
		m_blue77.setOrigin(m_blue77.getWidth()/2, m_blue77.getHeight()/2);
		m_blue88.setOrigin(m_blue88.getWidth()/2, m_blue88.getHeight()/2);
		m_blue99.setOrigin(m_blue99.getWidth()/2, m_blue99.getHeight()/2);
		//
		m_background.setOrigin(m_background.getWidth()/2, m_background.getHeight()/2);
		m_reset_board.setOrigin(m_reset_board.getWidth()/2, m_reset_board.getHeight()/2);
		m_bound.setOrigin(m_bound.getWidth()/2, m_bound.getHeight()/2);
	}
	
	public static ResourceManagement GetInstance()
	{
		if(m_hInstance == null)
		{
			m_hInstance = new ResourceManagement();
		}
		return m_hInstance;
	}
	Sprite GetResource(ReSourceID id)
	{
		switch (id) {
		case RED00:
		{
			return m_red00;
		}
		case RED10:
		{
			return m_red11;
		}
		case RED20:
		{
			return m_red22;
		}
		case RED30:
		{
			return m_red33;
		}
		case RED40:
		{
			return m_red44;
		}
		case RED50:
		{
			return m_red55;
		}
		case RED60:
		{
			return m_red66;
		}
		case RED70:
		{
			return m_red77;
		}
		case RED80:
		{
			return m_red88;
		}
		case RED90:
		{
			return m_red99;
		}
		case BLUE00:
		{
			return m_blue00;
		}
		case BLUE10:
		{
			return m_blue11;
		}
		case BLUE20:
		{
			return m_blue22;
		}
		case BLUE30:
		{
			return m_blue33;
		}
		case BLUE40:
		{
			return m_blue44;
		}
		case BLUE50:
		{
			return m_blue55;
		}
		case BLUE60:
		{
			return m_blue66;
		}
		case BLUE70:
		{
			return m_blue77;
		}
		case BLUE80:
		{
			return m_blue88;
		}
		case BLUE90:
		{
			return m_blue99;
		}
		case BACKGROUND:
		{
			return m_background;
		}
		case BOUND:
		{
			return m_bound;
		}
		case RESET_BOARD:
		{
			return m_reset_board;
		}
		default:
		{
			return null;
		}
		
	}

}
	//get sprite by id and pointnumber
	Sprite GetSprite(int id, int numberpoint)
	{
		if(id==1)
		{
			switch (numberpoint) {
			case 1:
				return m_blue11;
			case 2:
				return m_blue22;
			case 3:
				return m_blue33;
			case 4:
				return m_blue44;
			case 5:
				return m_blue55;
			case 6:
				return m_blue66;
			case 7:
				return m_blue77;
			case 8:
				return m_blue88;
			case 9:
				return m_blue99;

			default:
				break;
			}
		}
		if(id==2)
		{
			switch (numberpoint) {
			case 1:
				return m_red11;
			case 2:
				return m_red22;
			case 3:
				return m_red33;
			case 4:
				return m_red44;
			case 5:
				return m_red55;
			case 6:
				return m_red66;
			case 7:
				return m_red77;
			case 8:
				return m_red88;
			case 9:
				return m_red99;

			default:
				break;
			}
		}
		return null;
	}
}